package com.example.ivideo_2211a.take

import com.example.common.mvi.BaseRepository
import com.example.common.mvi.NetworkResult
import com.example.common.mvi.NetworkConfig
import retrofit2.Response

/**
 * 视频发布Repository
 * 负责处理视频发布的网络请求
 */
class VideoPublishRepository : BaseRepository() {
    
    private val api: VideoPublishApi by lazy {
        NetworkConfig.createApiService<VideoPublishApi>(
            baseUrl = "http://10.161.9.80:7015/"
        )
    }
    
    /**
     * 发布视频
     * @param request 视频发布请求参数
     * @return Flow<NetworkResult<VideoPublishResponse>> 发布结果
     */
    fun publishVideo(request: VideoPublishRequest) = safeApiCall {
        api.publishVideo(request)
    }
    
    /**
     * 简单的发布视频方法
     * @param request 视频发布请求参数
     * @return NetworkResult<VideoPublishResponse> 发布结果
     */
    suspend fun simplePublishVideo(request: VideoPublishRequest): NetworkResult<VideoPublishResponse> {
        return simpleApiCall {
            api.publishVideo(request)
        }
    }
}
